//
//  ScoreView.m
//  KeleAppProject
//
//  Created by Cen Zhou on 2018/1/17.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "ScoreView.h"



@interface ScoreView()

@property (nonatomic, strong) UIView *praseView;
@property (nonatomic, strong) UIView *playNumView;
@property (nonatomic, strong) UIView *collectionView;
@property (nonatomic, strong) UIView *commentView;
@end


@implementation ScoreView




- (instancetype)init{
    if (self = [super init]) {
        [self loadSubviewsOnScoreView];
    }
    return self;
}


- (void)loadSubviewsOnScoreView{
    
    UIView *topView = [[UIView alloc]init];
    topView.backgroundColor = KLColor_A1;
    [self addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.height.mas_equalTo(178*HEIGHT);
    }];
    
    UIButton *backBtn = [[UIButton alloc]init];
    [backBtn setBackgroundImage:[UIImage imageNamed:@"icon_fanhui_baise"] forState:UIControlStateNormal];
    [topView addSubview:backBtn];
    [[backBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        if (self.signalDelegate) {
            [self.signalDelegate sendNext:nil];
        }
    }];
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topView).offset(32);
        make.left.equalTo(topView).offset(15*WIDTH);
//        make.width.mas_equalTo(10*WIDTH);
//        make.height.mas_equalTo(20*HEIGHT);
    }];
    
    UILabel *centerLb = [[UILabel alloc]init];
    centerLb.text = @"我的成绩";
    centerLb.textColor = [UIColor whiteColor];
    centerLb.font = [UIFont fontWithName:@"PingFangSC-Regular" size:18*WIDTH];
    [topView addSubview:centerLb];
    [centerLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(backBtn);
        make.centerX.equalTo(topView);
    }];
    
    
    UILabel *titleLb = [[UILabel alloc]init];
    titleLb.text = @"哇，你的成绩好棒棒";
    titleLb.textColor = [UIColor whiteColor];
    titleLb.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15*WIDTH];
    [topView addSubview:titleLb];
    [titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(topView);
        make.top.equalTo(centerLb.mas_bottom).offset(39*HEIGHT);
    }];
    // 得到的赞
    UIView *praseView = [[UIView alloc]init];
    self.praseView = praseView;
    praseView.backgroundColor = KLColor_A4;
    [self addSubview:praseView];
    [praseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topView.mas_bottom).offset(39*HEIGHT);
        make.left.equalTo(self).offset(23*WIDTH);
        make.width.height.mas_equalTo(155*WIDTH);
    }];
    
    UILabel *praseNum = [[UILabel alloc]init];
    praseNum.text = @"588";
    praseNum.textColor = [UIColor whiteColor];
    praseNum.font = [UIFont fontWithName:@"PingFangSC-Medium" size:31*WIDTH];
    [praseView addSubview:praseNum];
    [praseNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(praseView);
        make.top.equalTo(praseView).offset(34*HEIGHT);
    }];
    
    UILabel *praseTint = [[UILabel alloc]init];
    praseTint.text = @"得到的赞";
    praseTint.textColor = [UIColor whiteColor];
    praseTint.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15*WIDTH];
    [praseView addSubview:praseTint];
    [praseTint mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(praseView);
        make.top.equalTo(praseNum.mas_bottom).offset(23*HEIGHT);
    }];
    // 播放量
    UIView *playNumView = [[UIView alloc]init];
    self.playNumView = playNumView;
    playNumView.backgroundColor = KLColor_A5;
    [self addSubview:playNumView];
    [playNumView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topView.mas_bottom).offset(39*HEIGHT);
        make.left.equalTo(praseView.mas_right).offset(20*WIDTH);
        make.width.height.mas_equalTo(155*WIDTH);
    }];
    
    UILabel *playNum = [[UILabel alloc]init];
    playNum.text = @"1588";
    playNum.textColor = [UIColor whiteColor];
    playNum.font = [UIFont fontWithName:@"PingFangSC-Medium" size:31*WIDTH];
    [playNumView addSubview:playNum];
    [playNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(playNumView);
        make.top.equalTo(playNumView).offset(34*HEIGHT);
    }];
    
    UILabel *playTint = [[UILabel alloc]init];
    playTint.text = @"播放量";
    playTint.textColor = [UIColor whiteColor];
    playTint.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15*WIDTH];
    [playNumView addSubview:playTint];
    [playTint mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(playNumView);
        make.top.equalTo(playNum.mas_bottom).offset(23*HEIGHT);
    }];
    
    // 收藏数
    UIView *collectionNumView = [[UIView alloc]init];
    self.collectionView = collectionNumView;
    collectionNumView.backgroundColor = KLColor_A6;
    [self addSubview:collectionNumView];
    [collectionNumView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(praseView.mas_bottom).offset(20*HEIGHT);
        make.left.equalTo(praseView);
        make.width.height.mas_equalTo(155*WIDTH);
    }];
    
    UILabel *collectionNum = [[UILabel alloc]init];
    collectionNum.text = @"2588";
    collectionNum.textColor = [UIColor whiteColor];
    collectionNum.font = [UIFont fontWithName:@"PingFangSC-Medium" size:31*WIDTH];
    [collectionNumView addSubview:collectionNum];
    [collectionNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(collectionNumView);
        make.top.equalTo(collectionNumView).offset(34*HEIGHT);
    }];
    
    UILabel *collectionTint = [[UILabel alloc]init];
    collectionTint.text = @"收藏数";
    collectionTint.textColor = [UIColor whiteColor];
    collectionTint.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15*WIDTH];
    [collectionNumView addSubview:collectionTint];
    [collectionTint mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(collectionNumView);
        make.top.equalTo(collectionNum.mas_bottom).offset(23*HEIGHT);
    }];
    
    // 评论次数
    
    UIView *commentNumView = [[UIView alloc]init];
    self.commentView = commentNumView;
    commentNumView.backgroundColor = KLColor_A7;
    [self addSubview:commentNumView];
    [commentNumView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(collectionNumView);
        make.left.equalTo(playNumView);
        make.width.height.mas_equalTo(155*WIDTH);
    }];
    
    UILabel *commentNum = [[UILabel alloc]init];
    commentNum.text = @"988";
    commentNum.textColor = [UIColor whiteColor];
    commentNum.font = [UIFont fontWithName:@"PingFangSC-Medium" size:31*WIDTH];
    [commentNumView addSubview:commentNum];
    [commentNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(commentNumView);
        make.top.equalTo(commentNumView).offset(34*HEIGHT);
    }];
    
    UILabel *commentTint = [[UILabel alloc]init];
    commentTint.text = @"评论次数";
    commentTint.textColor = [UIColor whiteColor];
    commentTint.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15*WIDTH];
    [commentNumView addSubview:commentTint];
    [commentTint mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(commentNumView);
        make.top.equalTo(commentNum.mas_bottom).offset(23*HEIGHT);
    }];
    
}


- (void)layoutSublayersOfLayer:(CALayer *)layer{
    [super layoutSublayersOfLayer:layer];
    [self.praseView layoutIfNeeded];
    [self.praseView setRadiusWithValue:10*WIDTH];
    [self.playNumView layoutIfNeeded];
    [self.playNumView setRadiusWithValue:10*WIDTH];
    [self.collectionView layoutIfNeeded];
    [self.collectionView setRadiusWithValue:10*WIDTH];
    [self.commentView layoutIfNeeded];
    [self.commentView setRadiusWithValue:10*WIDTH];
}

@end
